package com.zwb.demo.easyweb.common.entity.response;

import lombok.Data;

/**
 * 返回结果
 *
 * @author zwb
 */
@Data
public class ResponseResult {

    /** 是否成功 */
    private boolean success;

    /** 状态码 */
    private int code;

    /** 提示信息 */
    private String message;

    /** 数据 */
    private Object data;

    public ResponseResult(ResultCode resultCode) {
        this.success = resultCode.success();
        this.code = resultCode.code();
        this.message = resultCode.message();
    }

    public ResponseResult message(String message) {
        this.message = message;
        return this;
    }

    public static ResponseResult ok() {
        return new ResponseResult(CommonCode.SUCCESS);
    }

    public static ResponseResult fail() {
        return new ResponseResult(CommonCode.FAIL);
    }

    public ResponseResult body(Object data) {
        this.data = data;
        return this;
    }
}
